CREATE TABLE [dbo].[tb_Rendiciones]
(
[idRendicion] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Fecha] [datetime] NOT NULL,
[FechaAprobacion] [datetime] NULL,
[Observaciones] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_Rendiciones] ON [dbo].[tb_Rendiciones]
 FOR UPDATE AS 
 IF (update(idRendicion)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_RegistroContable
		 SET Rendicion = (SELECT idRendicion FROM inserted)
		 WHERE tb_RegistroContable.Rendicion = (SELECT idRendicion FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end
GO
ALTER TABLE [dbo].[tb_Rendiciones] ADD CONSTRAINT [PK_tb_Rendiciones] PRIMARY KEY NONCLUSTERED  ([idRendicion]) ON [PRIMARY]
GO
